public class array1 {
    public static void main(String[] args) {
        System.out.println("Hello Array");
        //int[] nums = new int[3];
        //nums[0] = 1;
        //nums[1] = 1;
        //nums[2] = 2;
        int[] nums = {1, 1, 2};
        int k = removeDuplicates(nums);
        System.out.println("k="+k);
        for (int i = 0; i < nums.length; i++) {
            System.out.println("nums["+i+"]="+nums[i]);
        }

    }
    static int removeDuplicates(int[] nums) {
        int n = 0;
        for (int i=n; i< nums.length; i++) {
            if (i==0 || nums[i] != nums[i-1]) {
                nums[n] = nums[i];
                n++;    
            }

        }
        return n;
    }
}
